const { labelModels } = require("../../models"); //导入数据库操作模块dbModels.js
//获取标签
exports.getLabel = async (req, res) => {
    try {
      await labelModels
       .getLabel()
       .then((result) => {
          res.send({
            code: 200,
            data: result
          });
        });
    }
    catch (error) {
      res.send({
        code: 400,
        data: error,
      })
    }
  }
  
  //新建标签
  exports.addLabel = async (req, res) => {
    try {
      let data = req.body;
      await labelModels
      .addLabel(data.value)
      .then((result) => {
          res.send({
            code: 200,
            data: result
          });
        });
    } catch (error) {
      res.send({
        code: 400,
        data: error,
      })
    }
  }
  
  //删除标签
  exports.deleteLabel = async (req, res) => {
    try {
      let data = req.body;
      await labelModels
     .deleteLabel(data.id)
     .then((result) => {
          res.send({
            code: 200,
            data: result
          });
        });
    } catch (error) {
      res.send({
        code: 400,
        data: error,
      })
    }
  }